#unicode
#The Lab about Python
def powTest():
    pow(2,pow(2,4))
    if 0.1+0.2 == 0.3:
        print(right)
    else:
        x = round(0.1+0.2)
        print(x)

#数学运算:(+,-,*,/),//整除
"""
x%y
x**y 相等 pow(x,y)
"""
def powOr():
    if 3**4 == pow(3,4):
        print("x**y like pow(x,y)")
    print(3**0.5)
    print(pow(3,0.5))

"""
def->fuction
//基本功能函数
abs(x)
divmod(x,y)
pow(x,y[,z])
round(x[,d])
max(x1,...,xn)
min(x1,...,xn)
//数值转换函数
int(x)
float(x)
complex(x)
"""

#字符串的操作
'''
weekStr = "星期一星期二星期三星期四星期五星期六星期日"
weekId = int(input("weekday:"))
pos = (weekId - 1)*3
print(weekStr[pos:pos+3])
'''
"""
字符串函数
len(x)
str(x)
bin(x)
hex(x)
oct(x)
chr(x)
ord(x)
字符串方法
str.lower() and str.upper()
str.split(sep=None)
str.count(sub)
str.replace(old,new)
str.center(width[,fillchar])
str.strip(chars)
str.join(iter)
"""
#print("1 + 1 = 2 "+chr(10004))
#print("图形:\n{: ^10}".format("*"))

#random
"""
seed(x)
random()
randint(a,b)
randrange(m,n[,k])
getrandbits(k)
uniform(a,b)
choice(seq)
shuffle(seq)
"""
import random
random.seed(9)
random.random()

#function
"""
def <函数名>([参数]):
    函数体
    return [返回值]
"""
#其中，包括默认参数值写法和未知参数
#注意全局变量和局部变量
'''
{function(x,y=1,*b)
{return x,y,b
'''
#lambda函数
#<函数名> = lambda 参数:表达式
def fact(n):
    if n == 0:
        return 1
    else:
        return n*fact(n-1)

#print(fact(10))

#组合数据类型
'''
1 集合类型及操作
2 序列类型及操作
3 字典类型及操作
'''
#集合类型
'''
{},set()
集合之间是无序的
集合之间元素不同
集合之间元素使用，隔开
'''
A = {"python","java","c",123,('python',123)}
B = set("pypy123")
#集合操作符
'''
A | B并
A - B差
A & B交
S ^ T补
'''
"""
print(A | B)
print(B | A)
print(A - B)
print(B - A)
print(A & B)
"""
#集合函数
'''
S.add(x)
S.discard(x)
S.remove(x)
S.clear
S.pop()
S.copy()
len(S)
set(x)
'''
def testS():
    try:
        while True:
            print(A.pop(),end="")
    except:
        pass

#序列类型
"1,元组类型"
'''
操作符
() 或 tuple()
x in s
x not in s
s + t
s*n
s[i]
s[i:j:k]
'''
"""
通用函数
len(s)
min(s)
max(s)
s.index(x)
s.count(x)
"""
creature = "cat","dog","tiger"
color = "1",creature

"[2,列表类型]"
"""
操作函数
ls[i] = x
ls[i:j:k] = lt
del ls[i]
del ls[i:j:k]
ls += lt
ls *= n
ls.append(x)
ls.clear()
ls.copy()
ls.insert(i,x)
ls.pop(i)
ls.remove(x)
ls.reverse()
"""
ls = ["python",123,".io"]

#字典类型
"{<键>:<值>,<键>:<值>}"
d = {"中国":"北京","美国":"华盛顿"}
#print(d['中国'])

'''
函数和方法
del d[k]
k in d
d.keys()
d.values()
d.items()
d.get(k,<default>)
d.pop(k,<default>)
d.popitem()
d.clear()
len(d)
'''
#jieba库
"""
jieba.lcut(s[,cut_all=True])
jieba.lcut_for_search(s)
jieba.add_word(s)
"""

#文件和数据格式化
'''
文本文件展示文件的内容，二进制文件展示文本的存储样式
'''
#一维数据-{对等关系，有序或无序组成}
"使用列表或者集合，有序-列表，无序-集合"
def readTxt():
    txt = open(fname).read()
    ls = txt.split()
    f.close()
    return ls, txt
def writeTxt():
    ls = ['中国','美国','日本']
    f = open(fname,'w')
    f.write(' '.join(ls))
    f.close()
    return f, ls

#二维数据-{多组一维数据结构组成}
"使用二维列表类型"
def csvRead():
    fo = open(fname)
    ls = []
    for line in fo:
        line = line.replace("/n","")
        ls.append(line.split(","))
    fo.close()
    return fo, line, ls
def csvWrite():
    ls = [[],[],[]]
    f = open(fname,'w')
    for item in ls:
        f.write(",".join(item)+"/n")
    f.close()
    return f, item, ls

#多维数据-{扩展自二维及一维数据}

#wordcloud库
'''
w = wordcloud.WordCloud()
w.generate(txt)
w.to_file(filename)
词云参数
width
height
min_font_size
max_font_size
font_step
font_path
max_words
stop_words
mask
background_color
'''
import wordcloud
def wordcloudUse():
    txt = "life is short, you need python"
    w = wordcloud.WordCloud(\
        background_color = "white")
    w.generate(txt)
    w.to_file("pycloud1.png")

wordcloudUse()